from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import IndexView, CategoryListView, GoodsListView, CartViewSet

# 创建路由器并注册视图集
router = DefaultRouter()
router.register(r'cart', CartViewSet, basename='cart')

urlpatterns = [
    # 首页数据API
    path('index/', IndexView.as_view(), name='index'),
    # 分类列表API
    path('categories/', CategoryListView.as_view(), name='categories'),
    # 商品列表API
    path('goods/', GoodsListView.as_view(), name='goods'),
    # 包含视图集的URL
    path('', include(router.urls)),
]